<?php
/**
 * 描述：资讯-专题首页。
 * @final
 */
final class Exec_News_Topic_Index
{
    public function __Construct()
    {
        #绑定类别
        View::Assign('TopicClass_News_ID',DAO_TopicClass::News_ID);
        View::Assign('TopicClass_Ship_ID',DAO_TopicClass::Ship_ID);
        View::Assign('TopicClass_Ancillary_ID',DAO_TopicClass::Ancillary_ID);
        View::Assign('TopicClass_Shipping_ID',DAO_TopicClass::Shipping_ID);

        #获取数据-最新资讯
        View::Assign('News_Latest',DAO_News::Latest());

        #获取数据-新闻专题
        $data=DB::GetRows('select * from topic where ClassID='.DAO_TopicClass::News_ID.' order by Datetime desc limit 0,5');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Topic_News_Topside',@$data[0]);
        View::Assign('Topic_News',array_slice($data,1,count($data)));

        #获取数据-船舶专题
        $data=DB::GetRows('select * from topic where ClassID='.DAO_TopicClass::Ship_ID.' order by Datetime desc limit 0,5');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Topic_Ship_Topside',@$data[0]);
        View::Assign('Topic_Ship',array_slice($data,1,count($data)));

        #获取数据-船配专题
        $data=DB::GetRows('select * from topic where ClassID='.DAO_TopicClass::Ancillary_ID.' order by Datetime desc limit 0,5');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Topic_Ancillary_Topside',@$data[0]);
        View::Assign('Topic_Ancillary',array_slice($data,1,count($data)));

        #获取数据-船运专题
        $data=DB::GetRows('select * from topic where ClassID='.DAO_TopicClass::Shipping_ID.' order by Datetime desc limit 0,5');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Topic_Shipping_Topside',@$data[0]);
        View::Assign('Topic_Shipping',array_slice($data,1,count($data)));

        #获取数据-专题排行
        $data=DB::GetRows('select * from topic order by VisitsCount desc limit 0,5');
        foreach($data as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }
        View::Assign('Topic_Ranking',$data);

        #渲染输出
        View::Display('news/topic/index.tpl');
    }
}
?>